package org.balthie.demo.jdk.nio.reactor.singleThread;

import java.io.IOException;
import java.nio.channels.Selector;
import java.nio.channels.ServerSocketChannel;
import java.nio.channels.SocketChannel;

public class Acceptor implements Runnable {
	final Selector selector;
	final ServerSocketChannel serverSocket;
	
	Acceptor(Selector selector, ServerSocketChannel serverSocket) {
		super();
		this.selector = selector;
		this.serverSocket = serverSocket;
	}

	public void run() {
		try {
			SocketChannel channel = serverSocket.accept();
			if (channel != null)
				new Handler(selector, channel);
		} catch (IOException ex) {
			/* ... */ }
	}
}
